#include <func.h>

void sigfunc(int signum,siginfo_t *p,void* p1)
{
    printf("before sleep,sig %d is coming!send pid=%d,send uid=%d\n",signum,p->si_pid,p->si_uid);
    sleep(2);
    //把内核中的pending信号集取出来
    sigset_t pending;
    sigpending(&pending);
    if(sigismember(&pending,SIGQUIT))
    {
        printf("sigquit is pending\n");
    }else{
         printf("sigquit is not pending\n");
    }
    printf("after sleep,sig %d is coming!\n",signum);
}
int main()
{
    struct sigaction act;//一定要清空
    bzero(&act,sizeof(act));
    act.sa_sigaction=sigfunc;//把信号处理函数赋给sa_sigaction
    act.sa_flags=SA_SIGINFO;//SA_SIGINFO加上后，sa_sigaction信号处理函数生效
    sigemptyset(&act.sa_mask);//清空掩码集合
    sigaddset(&act.sa_mask,SIGQUIT);
    int ret=sigaction(SIGINT,&act,NULL);
    ERROR_CHECK(ret,-1,"sigaction")
    while(1);
    // char buf[100]={0};
    // ret=read(STDIN_FILENO,buf,sizeof(buf));//read读标准输入
    // printf("ret=%d,buf=%s",ret,buf);
    return 0; 
}